﻿namespace EasyCMS.Common.DataComponents
{
    using System;
    using Pismire;




    ///<summary>
    ///EasyCMS
    ///</summary>
    ///<remarks>
    ///编写人: 唐炜
    ///编写时间 :2008-8-29
    ///修订历史
    ///---------------
    ///</remarks>
    [System.Runtime.Serialization.DataContractAttribute(Name = "Partition", Namespace = "http://schemas.datacontract.org/2004/07/EasyCMS.Common.DataComponents")]
    public class Partition : Pismire.Data.DBComponentBase
    {
        public Partition() { }

        public Partition(string mark, string displayName)
        {
            this.Mark = mark;
            this.DisplayName = displayName;
        }

        #region Mark
        /// <summary>
        /// 
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public string Mark
        {
            get { return m_Mark; }
            set { m_Mark = value; }
        }
        private string m_Mark;

        /// <summary>
        ///  正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState Mark_Validate(ref string mark)
        {
            return mark.Validation("Mark").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref mark).State;
        }
        #endregion

        #region Name
        /// <summary>
        /// 
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public string DisplayName
        {
            get { return m_DisplayName; }
            set { m_DisplayName = value; }
        }
        private string m_DisplayName;

        /// <summary>
        ///  正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState DisplayName_Validate(ref string displayName)
        {
            return displayName.Validation("DisplayName").LengthBetween(0, 50).Text(ValidationMode.Only).BindValue(ref displayName).State;
        }
        #endregion

        #region Memo
        /// <summary>
        /// 
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public string Memo
        {
            get { return m_Memo; }
            set { m_Memo = value; }
        }
        private string m_Memo;

        /// <summary>
        ///  正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState Memo_Validate(ref string memo)
        {
            return memo.Validation("Memo").LengthBetween(0, -1).Text(ValidationMode.Only).BindValue(ref memo).State;
        }
        #endregion

        #region AddTime
        /// <summary>
        /// 
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public DateTime AddTime
        {
            get { return m_AddTime; }
            set { m_AddTime = value; }
        }
        private DateTime m_AddTime;

        /// <summary>
        ///  正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState AddTime_Validate(ref DateTime addTime)
        {
            return addTime.Validation("AddTime").Between(Pismire.ConstValues.DateTime.MinValue, Pismire.ConstValues.DateTime.MaxValue).State;
        }
        #endregion


        #region IDBComponent Members

        /// <summary>
        /// 检查该实体的所有属性是否合法
        /// </summary>
        /// <returns></returns>
        public override ExcuteState CheckMe()
        {
            ExcuteState state = null;

            state = Mark_Validate(ref this.m_Mark);
            if (!state.Succeed) { return state; }

            state = DisplayName_Validate(ref this.m_DisplayName);
            if (!state.Succeed) { return state; }

            state = Memo_Validate(ref this.m_Memo);
            if (!state.Succeed) { return state; }

            state = AddTime_Validate(ref this.m_AddTime);
            if (!state.Succeed) { return state; }

            return state;
        }

        #endregion
    }
}
